package com.receiver;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.Toast;

public class receiver extends Activity {
    
	SMSReceiver receiver=null;
	IntentFilter filter=null;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        changeReceiverStatus(1);
        
        startService(new Intent(receiver.this, PositionService.class)); 
    }
    
    //====================================================
    private void changeReceiverStatus(int status){
    	
    	try{
    		
    		if(receiver==null)
    			receiver=new SMSReceiver(this);
    		
    		if(filter==null){
	    		
    			filter = new IntentFilter();
	    		filter.addAction("android.provider.Telephony.SMS_RECEIVED");
    		}
    		
    		if(status<0)
    			this.unregisterReceiver(receiver);
    		else
    			this.registerReceiver(receiver, filter);
    			
    	}catch(Exception e){e.printStackTrace();}
    }
}